<template>
	<view>
		<!-- <u-navbar title="保存分润" left-text="" @leftClick="onClickBack" :placeholder="true" :fixed="true"
			:safeAreaInsetTop="true" :border="true"></u-navbar> -->
		<view class="bg-white padding">
			<view class="cu-steps">
				<view class="cu-item" :class="index>num?'':'text-blue'" v-for="(item,index) in numList" :key="index">
					<text class="num" :class="index==2?'err':''" :data-index="index + 1"></text> {{item.name}}
				</view>
			</view>
		</view>
		<view class="padding-2 flex align-center">
			<text class="text-grey">T+1成本</text>
		</view>

		<view class="cu-list menu">

			<view class="cu-item">
				<view class="content">

					<text class="text-black">借记卡</text>
					<text class="text-gray" style="margin-left: 180upx;">费率（%）
					</text>

					<u-number-box decimal-length="2" v-model="info.card_t1Debit" :value="info.card_t1Debit" :step="0.01" :min="0" :max="3"
						@change="valChange" style="margin-left: 490upx;margin-top: -50upx;"></u-number-box>

				</view>
			</view>



			<view class="cu-item">
				<view class="content">
					<text class="text-black">借记卡</text>
					<text class="text-gray" style="margin-left: 180upx;">封顶（元）</text>

					<u-number-box :value="0" :step="0.01" :min="18" :max="18" @change="valChange"
						style="margin-left: 490upx;margin-top: -50upx;"></u-number-box>

				</view>
			</view>



			<view class="cu-item">
				<view class="content">
					<text class="text-black">贷记卡</text>
					<text class="text-gray" style="margin-left: 180upx;">费率（%）</text>
					<u-number-box decimal-length="2" v-model="info.card_t1Credit" :value="info.card_t1Credit" :step="0.01" :min="0"
						:max="3" @change="valChange" style="margin-left: 490upx;margin-top: -50upx;"></u-number-box>
				</view>
			</view>

			<view class="cu-item">
				<view class="content">
					<text class="text-black">境外卡</text>
					<text class="text-gray" style="margin-left: 180upx;">费率（%）</text>
					<u-number-box decimal-length="2" v-model="info.card_t1OverSee" :value="info.card_t1OverSee" :step="0.1" :min="0"
						:max="50" @change="valChange" style="margin-left: 490upx;margin-top: -50upx;"></u-number-box>
				</view>
			</view>


			<view class="cu-item">
				<view class="content">

					<text class="text-black">微信</text>
					<text class="text-gray" style="margin-left: 210upx;">费率（%）
					</text>

					<u-number-box decimal-length="2" v-model="info.weixin_t1" :value="info.weixin_t1" :step="0.01" :min="0" :max="3"
						@change="valChange" style="margin-left: 490upx;margin-top: -50upx;"></u-number-box>

				</view>
			</view>


			<view class="cu-item">
				<view class="content">

					<text class="text-black">支付宝</text>
					<text class="text-gray" style="margin-left: 180upx;">费率（%）
					</text>

					<u-number-box decimal-length="2" v-model="info.alipay_t1" :value="info.alipay_t1" :step="0.01" :min="0" :max="3"
						@change="valChange" style="margin-left: 490upx;margin-top: -50upx;"></u-number-box>

				</view>
			</view>

		</view>
		<view class="padding-2 flex align-center">
			<text class="text-grey">T+0成本</text>
		</view>

		<view class="cu-list menu">

			<view class="cu-item">
				<view class="content">
					<text class="text-black">借记卡</text>
					<text class="text-gray" style="margin-left: 180upx;">费率（%）</text>
					<u-number-box decimal-length="2" v-model="info.card_t0Debit" :value="info.card_t0Debit" :step="0.01" :min="0" :max="3"
						@change="valChange" style="margin-left: 490upx;margin-top: -50upx;"></u-number-box>
				</view>
			</view>




			<view class="cu-item">
				<view class="content">
					<text class="text-black">贷记卡</text>
					<text class="text-gray" style="margin-left: 180upx;">费率（%）</text>
					<u-number-box decimal-length="2" v-model="info.card_t0Credit" :value="info.card_t0Credit" :step="0.01" :min="0"
						:max="3" @change="valChange" style="margin-left: 490upx;margin-top: -50upx;"></u-number-box>
				</view>
			</view>
			<view class="cu-item">
				<view class="content">
					<text class="text-black">境外卡</text>
					<text class="text-gray" style="margin-left: 180upx;">费率（%）</text>
					<u-number-box decimal-length="2" v-model="info.card_t0OverSee" :value="info.card_t0OverSee" :step="0.1" :min="0"
						:max="50" @change="valChange" style="margin-left: 490upx;margin-top: -50upx;"></u-number-box>
				</view>
			</view>
			<view class="cu-item">
				<view class="content">
					<text class="text-black">单笔手续费</text>
					<text class="text-gray" style="margin-left: 180upx;">元/笔</text>
					<u-number-box :value="0" :step="1" :min="1" :max="20" @change="valChange"
						style="margin-left: 490upx;margin-top: -50upx;"></u-number-box>
				</view>
			</view>

		</view>

		<view class="padding-2 flex align-center">
			<text class="text-grey">银联二维码T+1成本(1000以上)</text>
		</view>
		<view class="cu-list menu">
			<view class="cu-item">
				<view class="content">
					<text class="text-black">借记卡</text>
					<text class="text-gray" style="margin-left: 180upx;">费率（%）</text>

					<u-number-box decimal-length="2" v-model="info.unionScan_t1Debit" :value="info.unionScan_t1Debit" :step="0.01" :min="0"
						:max="3" @change="valChange" style="margin-left: 490upx;margin-top: -50upx;"></u-number-box>
				</view>
			</view>
			<view class="cu-item">
				<view class="content">
					<text class="text-black">贷记卡</text>
					<text class="text-gray" style="margin-left: 180upx;">费率（%）</text>

					<u-number-box decimal-length="2" v-model="info.unionScan_t1Credit" :value="info.unionScan_t1Credit" :step="0.01"
						:min="0" :max="3" @change="valChange" style="margin-left: 490upx;margin-top: -50upx;">
					</u-number-box>
				</view>
			</view>

		</view>
		<view class="padding-2 flex align-center">
			<text class="text-grey">银联二维码T+1成本(1000以下)</text>
		</view>
		<view class="cu-list menu">

			<view class="cu-item">
				<view class="content">
					<text class="text-black">借记卡</text>
					<text class="text-gray" style="margin-left: 180upx;">费率（%）</text>
					<u-number-box decimal-length="2" v-model="info.unionScan2_t1Debit" :value="info.unionScan2_t1Debit" :step="0.01"
						:min="0" :max="3" @change="valChange" style="margin-left: 490upx;margin-top: -50upx;">
					</u-number-box>
				</view>
			</view>




			<view class="cu-item">
				<view class="content">
					<text class="text-black">贷记卡</text>
					<text class="text-gray" style="margin-left: 180upx;">费率（%）</text>
					<u-number-box decimal-length="2" v-model="info.unionScan2_t1Credit" :value="info.unionScan2_t1Credit" :step="0.01"
						:min="0" :max="3" @change="valChange" style="margin-left: 490upx;margin-top: -50upx;">
					</u-number-box>
				</view>
			</view>

		</view>

		<view class="padding flex flex-direction">
			<button class="cu-btn bg-blue lg" style="height: 90upx;" @click="submit">保存</button>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				numList: [{
					name: '基本信息'
				},  {
					name: '成本信息'
				}, ],
				num: 0,
				scroll: 0,
				user_id: null,
				type: null,
				info: []
			}

		},
		onLoad(option) {
			this.user_id = option.id || option.user_id;
			this.type = option.type
			this.initData()
		},
		methods: {
			onClickBack() {
				uni.navigateBack()
			},
			async initData() {
				let params = {
					agentid: this.user_id,
					type: this.type
				}
				const res = await this.$API({
					url: '/api/index/profit_sharing',
					method: "GET",
					data: params
				})
				if (res.code === 1) {
					this.info = res.data;
				}
			},

			async submit() {
				let params = {
					agentid: this.user_id,
					weixin_t0: this.info.weixin_t0,
					weixin_t1: this.info.weixin_t1,
					alipay_t0: this.info.alipay_t0,
					alipay_t1: this.info.alipay_t1,
					unionScan_t1Credit: this.info.unionScan_t1Credit,
					unionScan_t0Credit: this.info.unionScan_t0Credit,
					unionScan_t1Debit: this.info.unionScan_t1Debit,
					unionScan_t0Debit: this.info.unionScan_t0Debit,
					unionScan2_t1Credit: this.info.unionScan2_t1Credit,
					unionScan2_t0Credit: this.info.unionScan2_t0Credit,
					unionScan2_t1Debit: this.info.unionScan2_t1Debit,
					unionScan2_t0Debit: this.info.unionScan2_t0Debit,
					card_t1Credit: this.info.card_t1Credit,
					card_t0Credit: this.info.card_t0Credit,
					card_t1Debit: this.info.card_t1Debit,
					card_t0Debit: this.info.card_t0Debit,
					card_t1OverSee: this.info.card_t1OverSee,
					card_t0OverSee: this.info.card_t0OverSee
				}
				const res = await this.$API({
					url: '/api/index/addagent',
					method: "GET",
					data: params
				})
				if (res.code === 1) {
					uni.showToast({
						title: res.msg,
						icon: 'none',
						duration: 2000,
						success: (res) => {
							setTimeout(() => {
								uni.navigateBack()
							}, 1500)
						}
					})

				}
				this.num= this.num == this.numList.length - 1 ? 0 : this.num + 1
			},
			valChange(e) {
				console.log('当前值为: ' + e)
			}


		}
	}
</script>

<style>
	.padding-2 {
		padding: 25upx 40upx 25upx 40upx;

	}

	.tc {
		text-align: center;

	}
	.padding
	{
		padding: 6upx;
	}
</style>
